package serialization;

import java.io.*;

public class SuperNotSerial {
	public static void main(String[] args) {
		Dog3 d = new Dog3(35, "Fido");
		System.out.println("before: " + d.name + " " + d.weight);
		
		try {
			FileOutputStream fs = new FileOutputStream("testSerDog.ser");
			ObjectOutputStream os = new ObjectOutputStream(fs);
			os.writeObject(d);
			os.close();
		} catch (Exception e) { e.printStackTrace(); }
		
		try {
			FileInputStream fis = new FileInputStream("testSerDog.ser");
			ObjectInputStream ois = new ObjectInputStream(fis);
			d = (Dog3)ois.readObject();
			ois.close();
		} catch (Exception e) { e.printStackTrace(); }
		
		System.out.println("after: " + d.name + " " + d.weight);
	}
}

class Dog3 extends Animal implements Serializable {
	String name;
	//transient String name;
	Dog3(int w, String n) {
		weight = w;	//inherited
		name = n;	//not inherited
	}
}

class Animal {	//not serializable
	int weight = 42;
}
